using System;
using System.Configuration.Provider;

namespace NSecurity
{
    public class AccessControlProviderCollection<TSecurable, TVerb, TSubject> : ProviderCollection
        where TSecurable : class
        where TVerb : class
        where TSubject : class
    {
        public new AccessControlProviderBase<TSecurable, TVerb, TSubject> this[string name]
        {
            get { return (AccessControlProviderBase<TSecurable, TVerb, TSubject>)base[name]; }
        }

        public override void Add(ProviderBase provider)
        {
            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }

            if (provider is AccessControlProviderBase<TSecurable, TVerb, TSubject> == false)
            {
                throw new ArgumentException("Invalid provider type", "provider");
            }

            base.Add(provider);
        }
    }
}